const Router = require('koa-router')
const { Posts } = require('../../models/posts')
const router = new Router({
  prefix: '/v1/posts',
})
router.get('/list', async (ctx, next) => {
  const { pageIndex, pageSize, title, userid } = ctx.request.query
  const list = await Posts.getPostsList(Number(pageIndex || 1), Number(pageSize || 10), title, userid)
  ctx.body = {
    code: 200,
    data: list,
  }
})
module.exports = router

